package com.chen.dome10bufferedReader;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class BufferedwriterDome1 {
    //目标：创建一个字符输出流，将数据写入到文件中用字符缓冲进行包装
    public static void main(String[] args) {
        try (Writer fw = new FileWriter("D:\\学生成绩管理系统\\javaprojectmax\\d2_file-io\\src\\text.txt", true);
             // 创建一个字符缓冲流并且新增换行功能
             BufferedWriter bw = new BufferedWriter(fw);
        ) {
            bw.newLine();
            bw.write("hello world");
            bw.newLine();
            bw.write("陈世玉");
            bw.newLine();
            //用字符流写入数据
            bw.write("chen", 1, 2);
            bw.newLine();
            char[] chs = "陈世玉Java".toCharArray();
            bw.write(chs);
            bw.newLine();
            bw.write(chs, 0, 3);

//            fw.flush();
//            System.out.println("写入完毕");
//            fw.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
